package com.ziyun.erp.web.modules.order.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.order.entity.OrderTaxEntity;
import com.ziyun.erp.modules.order.service.OrderTaxService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 订单发票表
 *
 * @author 'lu'
 * @email 
 * @date 2018-10-13 17:31:39
 */
@RestController
@RequestMapping("order/ordertax")
public class OrderTaxController {
    @Autowired
    private OrderTaxService orderTaxService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("order:ordertax:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderTaxService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orderId}")
    @RequiresPermissions("order:ordertax:info")
    public R info(@PathVariable("orderId") Long orderId){
        OrderTaxEntity orderTax = orderTaxService.selectById(orderId);

        return R.ok().put("orderTax", orderTax);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("order:ordertax:save")
    public R save(@RequestBody OrderTaxEntity orderTax){
        orderTaxService.insert(orderTax);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("order:ordertax:update")
    public R update(@RequestBody OrderTaxEntity orderTax){
        ValidatorUtils.validateEntity(orderTax);
        orderTaxService.updateAllColumnById(orderTax);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("order:ordertax:delete")
    public R delete(@RequestBody Long[] orderIds){
        orderTaxService.deleteBatchIds(Arrays.asList(orderIds));

        return R.ok();
    }

}
